package cn.wolfcode.web.controller;

import cn.wolfcode.web.domain.Department;
import cn.wolfcode.web.domain.Employee;
import cn.wolfcode.web.jsonResult.JsonResult;
import cn.wolfcode.web.page.PageResult;
import cn.wolfcode.web.query.QueryObject;
import cn.wolfcode.web.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class LoginController {
    @Autowired
    private ILoginService loginService;
    @RequestMapping("/login")
    @ResponseBody
    public JsonResult login(String username, String password , HttpSession session) {
        try {
            Employee employee = loginService.selectUsernameAndPassword(username, password);
            session.setAttribute("employee",employee);
            return new JsonResult(true,"亲,欢迎登录");
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult(false,"亲,错误");
        }

    }

}
